home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / POINTERS.SWG / 0001_Array Of Pointers.pas next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  1.0 KB  |  45 lines

  1. {
  2. AW>Hi all! how do i pass an array of pointers to a procedure? i know how to
  3. AW>do it in C++, but is it been done in pascal?
  4.  
  5. Something like this :
  6. }
  7.  
  8. Const
  9.      MaxPointer = 20;
  10.  
  11. Type
  12.     MyPointerArrayType = Array [1..MaxPointer] of Pointer;
  13.  
  14. Var
  15.    MainPointerArray : MyPointerArrayType;
  16.  
  17. *Only give the pointer to the array to the procedure*
  18. This method allows you to alter the original variable.
  19.  
  20. procedure ProcessPointers1 (Var LocalArray : MyPointerArrayType);
  21.  
  22. begin
  23.      {Do something} 
  24. end;
  25.  
  26. *make a copy of the array*
  27. This method makes a copy of the array, and allows you to precess the array in 
  28. the procedure.
  29.  
  30. Procedure ProcessPointers2 (LocalArray : MyPointerArrayType);
  31.  
  32. begin
  33.      {Do something}
  34. end;
  35.  
  36. begin {Main}
  37.      MainPointerArray [1] := NIL;
  38.      ProcessPointers1 (MainPointerArray);     
  39.      ProcessPointers2 (MainPointerArray);
  40. end.{Main}
  41.         
  42. What you must remember that you have to declare a type first and then refer to
  43. this type when you declare a function or procedure.
  44.  
  45.